﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.Account.Model;
using Yipusoft.MapInfo.Model;
using Yipusoft.ProfessionalTeam.DAL;

public partial class MapInfo_DepartmentInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) 
        Bind();
    }

    private void Bind()
    {
        string DepartmentID=string.Empty;
        if (Request["departmentID"] != null)
        {
            if (!Request["DepartmentID"].Substring(0, 2).Equals("13"))
                DepartmentID = "13" + Request["departmentID"];
            else
                DepartmentID = Request["departmentID"];

         
          Yipusoft.MapInfo.Model.DepartmentIntroInfo info=  Yipusoft.MapInfo.BLL.DepartmentIntroduce.GetModel(DepartmentID);
          if (info == null)
              return;

          ShowInfo(info);
         
        }

    }

    public string GetAID()
    {
         string DepartmentID=string.Empty;
        if (Request["departmentID"] != null)
        {
            if (!Request["DepartmentID"].Substring(0, 2).Equals("13"))
                DepartmentID = "13" + Request["departmentID"];
            else
                DepartmentID = Request["departmentID"];
        }
        TeamDataContext team = new TeamDataContext();
        Assault assault= team.Assault.Where(o => o.DepartmentId == DepartmentID && o.TypeId == 4).FirstOrDefault();
        return assault != null ? assault.Id.ToString() : "";
    }
    private void ShowInfo(DepartmentIntroInfo model)
    {
    
        this.lblDepartmentName.Text = model.DepartmentName;
        this.lblDepartmentAddress.Text = model.DepartmentAddress;
        this.lblCreateDate.Text = model.CreateDate.Value.ToShortDateString();
        this.lblDepartmentAreaSize.Text = model.DepartmentAreaSize.ToString() + "平方米";
        this.lblBuildAreaSize.Text = model.BuildAreaSize.ToString()+"平方米";

        this.lblOfficerCount.Text = model.PeopleCount.ToString().Trim() != "" ? model.PeopleCount.ToString() + "人" : "";       
        this.lblDutyCarCount.Text =  model.DutyCarCount.ToString().Trim()!=""? model.DutyCarCount.ToString().Trim()+"辆":"";

        this.lblMangerDepartment.Text = model.MangerDepartment;
        this.lblBianzhi.Text = model.OfficerCount.ToString();

        lblDadui2.Text = model.EmployeeCount.ToString();
        lblMangerDepartment.Text = model.ContractCount.ToString();

        DepartmentImage.ImageUrl = model.Picture;

    }
    public string GetDepartmentName()
    {
        if (Request["DepartmentID"] == null)
            return "";
        string DepartmentID = Request["DepartmentID"].Substring(0, 2).Equals("13") ? Request["DepartmentID"] : "13" + Request["DepartmentID"];
        return Yipusoft.Account.BLL.Department.GetDepartment(DepartmentID).FullName + "  (点击设置单位信息)";

    }
  
}
